<!DOCTYPE html>
<html lang="en">
<head>

	<meta charset="utf-8">
	<title>Edit Appliance</title>
	<link rel="stylesheet" href="<?php echo base_url();?>/application/development-bundle/themes/custom-theme/jquery.ui.all.css">
	<link rel="stylesheet" href="<?php echo base_url();?>/application/css/style.css">
	<script src="<?php echo base_url();?>/application/development-bundle/jquery-1.4.4.js"></script>
	<script src="<?php echo base_url();?>/application/development-bundle/ui/jquery.ui.core.js"></script>
	<script src="<?php echo base_url();?>/application/development-bundle/ui/jquery.ui.widget.js"></script>
	<script src="<?php echo base_url();?>/application/development-bundle/ui/jquery.ui.accordion.js"></script>
	<script src="<?php echo base_url();?>/application/development-bundle/ui/jquery.ui.datepicker.js"></script>
	<link rel="stylesheet" href="<?php echo base_url();?>/application/development-bundle/demos/demos.css">
	
	<style>
		#accordion {width: 310px;}
	</style>
	
	<script>
	$(function() {
		$( "#accordion" ).accordion({
			autoHeight: false,
			navigation: true,
			collapsible: true
		});
	});
	</script>
	
	<script>
	$(function() {
		$( "#datepicker" ).datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'yy/mm/dd',
			yearRange: '1950:2099'
		});
	$(function() {
		$( "#datepicker2" ).datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'yy/mm/dd',
			yearRange: '1950:2099'
		});
	});
	});
	</script>
	
	<script>
	function OnSubmitForm(){
		if(document.pressed == "Save Changes"){
			if(document.adminform.student_number.value!=""){
				document.adminform.action ="<?php echo base_url();?>/index.php/applianceController/editAppliance";
				return true;
			}else{
				alert("Please enter student number!");
				return false;
			}
		
		}else if(document.pressed == "Main Menu"){
			document.adminform.action ="<?php echo base_url();?>/index.php/adminPageController";
			return true;
		}
	}
	</script>
	
</head>

<body>

<div class="demo">
	
	<div id="header"><h1>ACCI eXtreme Information System</h1></div>

	<div id="accordion">
	
		<h3><a href="#section1">Edit an Appliance</a></h3>
		<form name="adminform" method="post" onSubmit="return OnSubmitForm();">
			<h2>Appliance Information for</h2>
			<div>
			<?php
				if($data->num_rows()>0){
					$row = $data->row();
					echo "<b>".$row->first_name.' '.$row->middle_name.' '.$row->last_name."<br/>";
					echo $row->student_number."<br/>";
					echo "<br/><center>".$row->type_of_appliance."</center></b>";	
					echo "<input type=\"hidden\" name=\"type_of_appliance\" value=\"".$row->type_of_appliance."\">";
					echo "<input type=\"hidden\" name=\"student_number\" value=\"".$row->student_number."\">";
				}	
			?>
			<hr/>
				<?php if($data->num_rows()>0){?>
				<?php foreach($data->result() as $row):?>
				<table id="centeredtext" >
					<tr>
						<td align="center"><br/>
							Date Installed:<br/><input type="text" size="30" name="date_installed" id="datepicker" value="<?php echo $row->date_installed;?>"/><br/>
							Date Cancelled:<br/><input type="text" size="30" name="date_cancelled" id="datepicker2" value="<?php echo $row->date_cancelled;?>"/><br/><br/>
							Remarks:<br/><textarea name="remark" cols="45" rows="4"><?php echo $row->remark;?></textarea><br/>
						</td>
					</tr>
				</table>
				<br/>
				<hr/>				
				<?php endforeach;?>
				<?php }else{?>
					Student not found<br/><br/>
				<?php }?>
				<input type="reset"/>
				<input type="submit" value="Save Changes" onClick="document.pressed=this.value" />
				<input type="submit" value="Main Menu" onClick="document.pressed=this.value" />
			</div>
		</form>
		
	</div><!-- End accordion -->

</div><!-- End demo -->

</body>
</html>
